@extends('layouts.agent')
@section('content')
    <style>
        .help-block{color:#333;margin-top:7px}
    </style>
    <div id="ribbon"><ol class="breadcrumb"><li>内容区</li></ol></div>
    <div class="content_wrapper">
        <aside>
            <header><i class="fa fa-fw fa-file"></i>订单详情</header>
            <section>
                <div class="row">
                    <div class="col-sm-12">
                        <form id="dataForm" onsubmit="return false;" class="form-horizontal" role="form">
                            <input type="hidden" name="pic" id="pic_val" value="">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">订单号：</label>
                                <div class="col-sm-2 help-block">
                                    {{$order['order_num']}}
                                </div>
                                <label class="col-sm-2 control-label">订单额：</label>
                                <div class="col-sm-2 help-block">
                                    {{$order['money']}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">支付状态：</label>
                                <div class="col-sm-2 help-block">
                                    {{$order['pay_status'] == 1 ? '已支付' : '未支付'}}
                                </div>
                                <label class="col-sm-2 control-label">订单状态：</label>
                                <div class="col-sm-2 help-block">
                                    {{$statusLabels[$order['status']]}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">快递单号：</label>
                                <div class="col-sm-2 help-block" id="express-show">
                                    {{$order['express_num']}}
                                </div>
                                <label class="col-sm-2 control-label">下单人：</label>
                                <div class="col-sm-2 help-block">
                                    {{$order['user']['nickname']}} - {{$order['user']['username']}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">收货人：</label>
                                <div class="col-sm-2 help-block">
                                    {{$order['name']}} - {{$order['mobile']}}
                                </div>
                                <label class="col-sm-2 control-label">收货地址：</label>
                                <div class="col-sm-5 help-block">
                                    {{$order['address']}}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">备注：</label>
                                <div class="col-sm-9 help-block">
                                    {{$order['remark']}}
                                </div>
                            </div>
                            <hr/>

                            @foreach($details as $v)
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">商品：</label>
                                    <div class="col-sm-2 help-block">
                                        {{$v['name']}}
                                    </div>
                                    <label class="col-sm-2 control-label">单价：</label>
                                    <div class="col-sm-2 help-block">
                                        {{$v['price']}}
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">数量：</label>
                                    <div class="col-sm-2 help-block">
                                        {{$v['num']}}
                                    </div>
                                    <label class="col-sm-2 control-label">金额：</label>
                                    <div class="col-sm-2 help-block">
                                        {{$v['money']}}
                                    </div>
                                </div>
                                <hr>
                            @endforeach

                            @if($order['pay_status'] == 1 && $order['status'] == 0)
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">快递单号：</label>
                                    <div class="col-sm-3">
                                        <input type="text" id="express" value="{{$order['express_num']}}" class="form-control" maxlength="30">
                                    </div>
                                    <div class="col-sm-3">
                                        <input type="button" class="btn btn-primary" value="保存" id="saveBtn" onclick="saveData()" />&nbsp;&nbsp;&nbsp;
                                    </div>
                                </div>
                                <hr>
                            @endif

                            <div class="form-group">
                                <label class="col-sm-2 control-label"> </label>
                                <div class=" col-sm-10">
                                    <a href="/agent/order/index" class="btn btn-default">返回订单列表</a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </section>
        </aside>
    </div>
    <script>
        function saveData() {
            if ($('#express').val()) {
                $.get('{{url('agent/order/saveExpressNum')}}', {
                    order_id: '{{$order['id']}}',
                    express_num: $('#express').val()
                }, function () {
                    layer.msg('保存成功', {icon :1}, function () {
                        location.reload()
                    });
                });
            }
        }
    </script>
@endsection